﻿<!--#include file="../inc/common.asp" -->
<!--#include file="waputil.asp" -->
<%
  response.contentType="text/vnd.wap.wml"
  'response.contentType="text/html"
  response.charset=DEFAULT_CHARSET
  response.buffer = true  

  'on error resume next

  openDB()
  

  dim blogItem
  set blogItem = new BlogItemClass
  
  dim title, user_name, i, totalCount, pageSize, pageno, order, url, detail
  
  pageSize = 10
  pageno = request("pageno_comments")
  if pageno<>"" then
  	pageno = clng(pageno)
  else
    pageno = 1
  end if
  
  order = request("order")
  
  sql = "  from blog_comments a, blog_content b  where a.content_id = b.content_id and b.is_secret=false "
  if request("blog_id")<>"" then
    sql = sql & " and b.blog_id = " & blogObj.blogId
  end if
  if request("content_id")<>"" then
    blogItem.load(clng(request("content_id")))
    sql = sql & " and b.content_id = " & clng(request("content_id"))
  end if
  
  if request("blog_id")="" then
  	  totalCount = 20
  	  pageSize = 20
  	  order = "desc"
  else
      rs.open " select count(a.comment_id) as total_count " & sql,conn,1,1  
      totalCount = clng(rs("total_count"))
      rs.close
  end if  

  sql = " select top " & (pageNo * pageSize) & " b.blog_id, a.comment_id,a.detail,a.is_secret , b.title, a.content_id,  a.insert_time, a.user_name, a.is_secret as secret_comment, b.is_secret as secret_content " & sql
  
  if request("content_id")="" then
    sql = sql & " order by a.insert_time desc "
  else
    sql = sql & " order by a.insert_time "
  end if
  'response.write sql
  'response.end
  rs.open sql,conn,1,1  

%>
<?xml version="1.0" encoding="<%=DEFAULT_CHARSET%>"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapfourm.org/DTD/wml_1.1.xml">
<wml>
<card title="<%="最新评论"%>" newcontext="false" ordered="true">
<p align="left">
<%
if request("content_id")<>"" then
%>
<b><%=blogItem.title%></b><br/><br/>
<%
end if
%>
<%
  i = 1
  if not rs.eof then
  	rs.pageSize=pageSize
  	rs.absolutePage=pageNo

    do until rs.eof       
        title = rs("title")
        if strlen(title)>24 then
            title = strleft(title,22) & ".."
        end if
        user_name = rs("user_name")
        if strlen(user_name)>10 then
            user_name = strleft(user_name,8) 
        end if
        detail = trim(HTML2WML2(rs("detail"),false))
%>
<%=(pageno-1)*pageSize + i%>.<b><%=HTML2WML(user_name)%></b>：
<a href="comment.asp?blog_id=<%=rs("blog_id")%>&amp;content_id=<%=rs("content_id")%>&amp;comment_id=<%=rs("comment_id")%>&amp;pageno_list=<%=request("pageno_list")%>&amp;pageno_comments=<%=request("pageno_comments")%>">
<%
	if rs("is_secret")<>false then
		response.write "--悄悄话--"
	else
		response.write strLeft(detail,60)
	end if
%>
<%
	if strlen(detail)>60 then
		response.write(">>")
	end if
%>
</a><br/>&nbsp;<%=rs("insert_time")%><br/><br/>
<%
        i = i+1
        rs.moveNext()
    loop
  end if
  url = "comments.asp?blog_id=" & request("blog_id") & "&amp;content_id=" & request("content_id") & "&amp;pageno_list=" & request("pageno_list")
%>
<%=wmlPageLink2(pageno,  pageSize, totalCount, url, "pageno_comments")%><br/>
<%
  if request("content_id")<>"" then
%>
<a href="detail.asp?blog_id=<%=blogObj.blogId%>&amp;content_id=<%=request("content_id")%>&amp;pageno_list=<%=request("pageno_list")%>">[返回正文]</a><br/>
<%
  end if
%>
<a href="list.asp?blog_id=<%=blogObj.blogId%>&amp;pageno_list=<%=request("pageno_list")%>">[返回<%=HTML2WML(blogObj.blogTitle)%>首页]</a><br/>
<a href="index.asp">[返回站点首页]</a>
</p>
<%
  writeBlogOptions
%>
</card>
</wml>
<%
  closeDB()
  'session.abandon
%>